import gevent
import time
from gevent import monkey

monkey.patch_all()


def a():  # 任务A
    for i in range(5):
        print('A' + str(i))
        time.sleep(0.1)  # 感知到有耗时动作, 自动切换


def b():  # 任务B
    for i in range(5):
        print('B' + str(i))
        time.sleep(0.1)


def c():  # 任务C
    for i in range(5):
        print('C' + str(i))
        time.sleep(0.1)


if __name__ == '__main__':
    g1 = gevent.spawn(a)
    g2 = gevent.spawn(b)
    g3 = gevent.spawn(c)

    g1.join()
    g2.join()
    g3.join()
"""
A0
B0
C0
A1
B1
C1
A2
B2
C2
A3
B3
C3
A4
B4
C4
"""